﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using SharpMap.Tools;
using SharpMap.Rendering.Rendering2D;
using SharpMap.Presentation.Views;
using Props = SharpMap.Wpf.Properties;
using System.Collections.ObjectModel;
namespace SharpMap.Wpf
{
    public class MapTool :  SharpMap.Tools.MapTool,  IMapTool<IMapView2D, Point2D>
    {
        MapTask _activeTask;

        protected MapTool(String name)
            :base(name)
        {
        }
        private Collection<MapTask> _tasks;
  
        public Cursor Cursor { get; set; }

        public void SetActiveTask(MapTask task)
        {
            if (_activeTask != null)
            {
                throw new InvalidOperationException(Props.Resources.Error_TaskAlreadyActivated);
            }
            _activeTask = task;
        }

        public void ClearActiveTask()
        {
            _activeTask = null;
        }

        #region IMapTool<IMapView2D,Point2D> Members

  

        Action<ActionContext<IMapView2D, Point2D>> IMapTool<IMapView2D, Point2D>.QueryAction
        {
            get 
            {
                return (ActionContext<IMapView2D, Point2D> param) => _queryToolCommandBinding.Command.Execute(param);
            }
        }

        Action<ActionContext<IMapView2D, Point2D>> IMapTool<IMapView2D, Point2D>.BeginAction
        {
            get 
            {
                return (ActionContext<IMapView2D, Point2D> param) => _beginToolCommandBinding.Command.Execute(param);
            }
        }

        Action<ActionContext<IMapView2D, Point2D>> IMapTool<IMapView2D, Point2D>.ExtendAction
        {
            get
            {
                return (ActionContext<IMapView2D, Point2D> param) => _extendToolCommandBinding.Command.Execute(param);
            }
        }

        Action<ActionContext<IMapView2D, Point2D>> IMapTool<IMapView2D, Point2D>.EndAction
        {
            get 
            {
                return (ActionContext<IMapView2D, Point2D> param) => _endToolCommandBinding.Command.Execute(param);
            }
        }

        #endregion


      
        CommandBinding _queryToolCommandBinding = new CommandBinding();
        CommandBinding _beginToolCommandBinding = new CommandBinding();
        CommandBinding _extendToolCommandBinding = new CommandBinding();
        CommandBinding _endToolCommandBinding = new CommandBinding();

        InputBinding _queryInputBinding;
        InputBinding _beginInputBinding;
        InputBinding _extendInputBinding;
        InputBinding _endInputBinding;

    }
}
